<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class calculate_byte extends CI_Controller {

	public function index($bytes)
	{		

	    if ($bytes > 0)
	    {
	        $unit = intval(log($bytes, 1024));
	        $units = array('B', 'KB', 'MB', 'GB' ,'TB');

	        if (array_key_exists($unit, $units) === true)
	        {
	            //printf('%.2f %s', $bytes / pow(1024, $unit), $units[$unit]);
	            $bytes = $bytes / pow(1024, $unit);

	            $sum_bytes[0] = $bytes;
	            $sum_bytes[1] = $units[$unit];
	            return $sum_bytes;

	        }
	    }

	}
	
}
